using System;
using System.Collections.Generic;
using System.Drawing;

namespace Woz
{
    /// <summary>
    /// the variables class
    /// </summary>
    public sealed class StaticVariables
    { 
        /// <summary>
        /// private default constructor
        /// </summary>
        private StaticVariables()
        {
            // initialize the media folder
            System.Reflection.Assembly staticVars = System.Reflection.Assembly.GetExecutingAssembly();
            string path = System.IO.Path.GetDirectoryName(staticVars.Location);
            if(System.IO.Directory.Exists(System.IO.Path.Combine(path, "media")))
            {
                this.mMediaFolder = System.IO.Path.Combine(path, "media");
            }
            else if (System.IO.Directory.Exists(System.IO.Path.Combine(System.IO.Directory.GetParent(path).FullName, "media")))
            {
                this.mMediaFolder = System.IO.Path.Combine(System.IO.Directory.GetParent(path).FullName, "media");
            }
            else
            {
                this.mMediaFolder = "media";
            }

            // initialize the canvas size
            this.mCanvasSize = new Size(1024, 768);

            // initialize the thumbnail size
            this.mThumbnailImageSize = new Size(96, 72);

            // initialize the thumbnail margin size
            //this.mThumbnailImageMargin = new Size(3, 3);

            // initialize the initial pen color
            this.mInitialPenColor = Color.Black;

            // initialize the initial background color
            this.mInitialBackgroundColor = Color.White;

            // initialize the initial pen thickness
            this.mInitialPenThickness = 100.0f;

            // intitialize the initial eraser size
            this.mInitialEraserSize = 15.0f;

            // initialize the maximum stretch tension
            this.mMaximumStretchTension = 100.0;

            // initialize the width of the toolbox and screen slider containers
            this.mToolboxContainerWidth = 115;
            this.mScreenSliderContainerWidth = 150;

            // initialize the paste offset
            this.mPasteOffset = 300;

            // initialize the percent area
            this.mSelectionPercentage = 0.65f;

            this.mDesignScreens = "DesignScreens";
            this.mEditScreenTransitions = "EditScreenTransitions";
            this.mRunScreens = "RunScreens";

            this.mDefaultScreenName = "Screen 1";
        }

        /// <summary>
        /// gets the single instance of the variables class
        /// </summary>
        public static StaticVariables Instance
        {
            get
            {
                // if the instance doesnt exist
                if (sInstance == null)
                {
                    // create it using delayed loading
                    sInstance = new StaticVariables();
                }

                // return the instance
                return sInstance;
            }
        }

        /// <summary>
        /// gets the path to the media folder
        /// </summary>
        public string MediaFolder
        {
            get
            {
                return this.mMediaFolder;
            }
        }

        /// <summary>
        /// gets the name of the default screen to be used in the screen manager
        /// </summary>
        public string DefaultScreenName
        {
            get
            {
                return this.mDefaultScreenName;
            }
        }

        /// <summary>
        /// gets the initial pen color
        /// </summary>
        public Color InitialPenColor
        {
            get
            {
                return this.mInitialPenColor;
            }
        }

        /// <summary>
        /// gets the initial background color
        /// </summary>
        public Color InitialBackgroundColor
        {
            get
            {
                return this.mInitialBackgroundColor;
            }
        }

        /// <summary>
        /// gets the initial eraser size
        /// </summary>
        public float InitialEraserSize
        {
            get
            {
                return this.mInitialEraserSize;
            }
        }

        /// <summary>
        /// gets the initial pen thickness
        /// </summary>
        public float InitialPenThickness
        {
            get
            {
                return this.mInitialPenThickness;
            }
        }

        /// <summary>
        /// gets the maximum amount of allowed stretch on a transition line
        /// </summary>
        public double MaximumStretchTension
        {
            get
            {
                return this.mMaximumStretchTension;
            }
        }

        /// <summary>
        /// gets the size of a thumbnail image
        /// </summary>
        public Size ThumbnailImageSize
        {
            get
            {
                return this.mThumbnailImageSize;
            }
        }

        /// <summary>
        /// gets the size of the thumbnail margins
        /// </summary>
        /*private Size ThumbnailImageMargin
        {
            get
            {
                return this.mThumbnailImageMargin;
            }
        }*/

        /// <summary>
        /// gets the ratio between thumbnail and canvas
        /// </summary>
        public float ThumbnailImageRatio
        {
            get
            {
                return (this.mThumbnailImageSize.Width / (float)this.mCanvasSize.Width);
            }
        }

        /// <summary>
        /// gets the size of the canvas
        /// </summary>
        public Size CanvasSize
        {
            get
            {
                return this.mCanvasSize;
            }
        }

        /// <summary>
        /// gets the maximum width of the tool options panel
        /// </summary>
        public int ToolOptionPanelsWidth
        {
            get
            {
                return this.mToolboxContainerWidth - 12;
            }
        }

        /// <summary>
        /// gets the size of the toolbox container width
        /// </summary>
        public int ToolboxContainerWidth
        {
            get
            {
                return this.mToolboxContainerWidth;
            }
        }

        /// <summary>
        /// gets the size of the screen slider container width
        /// </summary>
        public int ScreenSliderContainerWidth
        {
            get
            {
                return this.mScreenSliderContainerWidth;
            }
        }

        /// <summary>
        /// gets the amount things that get pasted are offset by in ink space
        /// </summary>
        public int PasteOffset
        {
            get
            {
                return this.mPasteOffset;
            }
        }

        /// <summary>
        /// gets the selection percentage
        /// </summary>
        public float SelectionPercentage
        {
            get
            {
                return this.mSelectionPercentage;
            }
        }

        /// <summary>
        /// gets the string representation of this mode
        /// </summary>
        public string DesignScreens
        {
            get
            {
                return this.mDesignScreens;
            }
        }

        /// <summary>
        /// gets the string representation of this mode
        /// </summary>
        public string EditScreenTransitions
        {
            get
            {
                return this.mEditScreenTransitions;
            }
        }

        /// <summary>
        /// gets the string representation of this mode
        /// </summary>
        public string RunScreens
        {
            get
            {
                return this.mRunScreens;
            }
        }

        /// <summary>
        /// the static instance of this singleton class
        /// </summary>
        private static StaticVariables sInstance;

        /// <summary>
        /// the path to the media folder
        /// </summary>
        private string mMediaFolder;

        /// <summary>
        /// the size of the thumbnail image
        /// </summary>
        private Size mThumbnailImageSize;

        /// <summary>
        /// the size of the thumbnail margin
        /// </summary>
        //private Size mThumbnailImageMargin;

        /// <summary>
        /// the size of the canvas
        /// </summary>
        private Size mCanvasSize;

        /// <summary>
        /// the initial pen color
        /// </summary>
        private Color mInitialPenColor;

        /// <summary>
        /// the initial background color
        /// </summary>
        private Color mInitialBackgroundColor;

        /// <summary>
        /// the initial pen thickness
        /// </summary>
        private float mInitialPenThickness;

        /// <summary>
        /// the initial eraser size
        /// </summary>
        private float mInitialEraserSize;

        /// <summary>
        /// the width of the toolbox container
        /// </summary>
        private int mToolboxContainerWidth;

        /// <summary>
        /// the width of the screen slider container
        /// </summary>
        private int mScreenSliderContainerWidth;

        /// <summary>
        /// the offset by which to offset things that get pasted in ink space
        /// </summary>
        private int mPasteOffset;

        /// <summary>
        /// the percentage of area of entity to select
        /// </summary>
        private float mSelectionPercentage;

        /// <summary>
        /// the maximum amount of allowed stretch on a transition line
        /// </summary>
        private double mMaximumStretchTension;

        /// <summary>
        /// string representations of the different modes
        /// </summary>
        private string mDesignScreens;
        private string mEditScreenTransitions;
        private string mRunScreens;

        /// <summary>
        /// name of the default screen in the screen manager
        /// </summary>
        private string mDefaultScreenName;
    }
}
